import Vue from 'vue'
import app from './app.vue'
import router from "./router"
import axios from 'axios'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import 'font-awesome/css/font-awesome.css'
import filter from "./filter/filter"

Vue.config.productionTip = false
Vue.prototype.$axios = axios

Vue.use(ElementUI)

// 事件总线EventBus
Vue.prototype.$event = new Vue()

// 全局过滤器
Object.keys(filter).forEach(key => {
  Vue.filter(key, filter[key])
})

/**
 * axios拦截器
 */
axios.interceptors.request.use(function (config) {
  console.log("请求：", config);
  return config;
}, error => {});
axios.interceptors.response.use(function (response) {
  console.log("返回结果：", response);
  return response;
},  error => {});

/**
 * 每次切换页面时, 窗口回到顶部
 */
router.afterEach((to,from,next) => {
  window.scrollTo(0,0);
});

new Vue({
  router,
  render: h => h(app),
}).$mount('#app')